package org.geometerplus.android.fbreader;

import java.util.HashMap;
import java.util.Map;

import org.geometerplus.android.fbreader.library.SQLiteBooksDatabase;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
import org.geometerplus.fbreader.library.Book;
import org.geometerplus.fbreader.library.BooksDatabase;
import org.geometerplus.fbreader.library.FileInfoSet;
import org.geometerplus.fbreader.library.ImageUtil;
import org.geometerplus.fbreader.library.Library;
import org.geometerplus.zlibrary.core.application.ZLApplication;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.image.ZLImage;
import org.geometerplus.zlibrary.core.image.ZLLoadableImage;
import org.zixuanstudio.ebook.R;
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidActivity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class ReaderWelcomeActivity extends Activity {

	private static final long WAITS_TIME = 300;
	
	private Handler mHandler = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			initBooksDatabases();
			Intent intent = new Intent(ReaderWelcomeActivity.this,BookShelf.class);
			startActivity(intent);
			finish();
		}
		
	};
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Thread.setDefaultUncaughtExceptionHandler(
				new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)
			);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN ,    
                WindowManager.LayoutParams. FLAG_FULLSCREEN); 
		
		if (SQLiteBooksDatabase.Instance() == null) {
			new SQLiteBooksDatabase(this, "READER");
			
		}
		
		
		setContentView(R.layout.welcome);
		
		//ImageUtil.startLoadBookCover(this,mHandler);
		mHandler.sendEmptyMessageDelayed(0, WAITS_TIME);
	}
	/*protected ZLApplication createApplication(ZLFile file) {
		return null;
	}
	@Override
	protected ZLFile fileFromIntent(Intent intent) {
		return null;
	}*/
	/**
	 * 在初始化的时候，默认添加一本书
	 */
	private void initBooksDatabases() {
		//Book.getByFile(Library.getDefaultFile());
	}

}
